<template>
	<div id="userinfo">
		<div class="">
			<div class="title">
				升级为企业买家
			</div>
			<div class="detail_info">
				<el-form label-width="140px" style="">

					<el-form-item label="经营类目：">
						<div class="special_item">
							<div class="angel_select" @click="selectCategory()">
								<el-input onfocus="this.blur();" v-model="category.productCategoryNames" placeholder="请选择经营类目"></el-input>
								<img src="../../assets/centers/icon_arrow_spread_mine.png" />
							</div>
							<div class="category_component">
								
								<category ref="category" :params="params" :obj_="category" key_="productCategoryIds"></category>
							</div>
						</div>
					</el-form-item>
					<el-form-item label="企业简称：">
						<el-input v-model="params.shortName" :maxlength="25" type="text" placeholder="请填写企业简称"></el-input>
					</el-form-item>
					<el-form-item label="企业全称：">
						<el-input v-model="params.realName" :maxlength="50" type="text" placeholder="请填写企业全称（选填）"></el-input>
					</el-form-item>
					<el-form-item label="统一社会信用代码：">
						<el-input v-model="params.organCode" :maxlength="18" type="text" placeholder="请填写统一社会信用代码"></el-input>
					</el-form-item>
					
					<el-form-item label="法人姓名：">
						<el-input v-model="params.contactName" :maxlength="10" type="text" placeholder="请填写法人姓名"></el-input>
					</el-form-item>
					<el-form-item label="法人身份证：">
						<el-input v-model="params.idNo" type="text" placeholder="请填写法人身份证"></el-input>
					</el-form-item>
					<el-form-item label="联系电话：">
						<el-input v-model="params.contactTel" type="text" placeholder="请填写联系电话"></el-input>
					</el-form-item>
					<el-form-item label="地址：">
						<div class="addr_select" @click="selectAddress()">
							<el-input placeholder="请选择收货地址" v-model="params.addressPre"></el-input>
							<img src="../../assets/centers/icon_arrow_spread_mine.png" />
						</div>
					</el-form-item>
					<el-form-item label="详细地址：">
						<el-input type="textarea" placeholder="请输入详细地址信息" v-model="params.addressDetail"></el-input>
					</el-form-item>
					<el-form-item label="营业执照:">
						<v-imgupload :obj="params"></v-imgupload>
					</el-form-item>
					<el-form-item label="">
						<div class="infobtn my-flex-center" @click="submit">
							提交
						</div>
					</el-form-item>
				</el-form>

			</div>
		</div>
		<mapset :model="mapmodel" v-on:selectBack="selectBack"></mapset>
	</div>
</template>

<script>
	import mapset from '@/components/map/map.vue';
	import category from './category';
	import service from '@/js/common/customerservice.js';
	export default {
		components: {
			mapset,
			category,

		},
		data() {
			return {
			params: {
					id:null,
					code: '',
					productCategoryIds: '',
					productCategoryIdsCN: '',
					pwd: '',
					confirmPwd: '',
					tel: '',
					latitude: '',
					longitude: '',
					addressPre: '', //省市
					addressDetail: '',
					shortName: '', //企业简称
					realName: '', //企业全称:选填
					userName: '', //企业全称:选填
					contactName: '', //联系人名称
					contactTel: '', //联系电话
					businessLicense: '',
					idNo:'', 
					organCode:null,//企业统一社会信用代码
				},
				category: {
					productCategoryNames: null
				},
				mapmodel: {
					visible: false,
					address: null,
					longitude: 0,
					latitude: 0,
					addressPre: '', //省市
					addressDetail: ''
				},
			}
		},
		computed: {
			productCategoryIds() {
				return this.category.productCategoryIds;
			}
		},
		watch: {
			productCategoryIds(val) {
				this.params.productCategoryIds = val.join(',');
			}
		},
		mounted() {
//			this.$nextTick(() => {
//				console.log(this.$route.params.id)
//				if(this.$route.params.id){
//					this.params.id = this.$route.params.id;
//				}else{
//					this.$router.go(-1);
//				}
//			})
		},
		methods: {
			...service,
			submit() {
				this.update();
			},
			selectCategory() {
				this.$refs.category.show(this.category.productCategoryIds);
			},
			selectAddress() {
				this.mapmodel.visible = true;
				this.mapmodel.longitude = this.params.longitude;
				this.mapmodel.latitude = this.params.latitude;
				this.mapmodel.address = this.params.addressPre;
			},
			selectBack(model) {
				this.params.addressPre = model.address;
				this.params.latitude = model.longitude;
				this.params.longitude = model.latitude;
			},
		}
	}
</script>

<style lang="less" src="../../less/page/center/userinfo.less"></style>